package ksv.cron.v1;

import ksv.cron.v1.impl.DefaultCronCallbackPostProcessor;
import ksv.cron.v1.impl.DefaultCronContainer;
import ksv.cron.v1.impl.MysqlCronLoader;
import ksv.cron.v1.impl.OkHttpCronCallback;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @创建人 wsdc
 * @时间 2021/1/31
 * @描述 $
 */
@Configuration
public class CronConfiguration {
    @Bean
    @ConditionalOnMissingBean(Looper.class)
    public Looper looper(){
        return new Looper();
    }

    @Bean
    @ConditionalOnMissingBean(CronContainer.class)
    public CronContainer cronContainer(){
        return new DefaultCronContainer();
    }

    @Bean
    @ConditionalOnMissingBean(CronLoader.class)
    public CronLoader cronLoader(){
        return new MysqlCronLoader();
    }

    @Bean
    @ConditionalOnMissingBean(CronCallbackPostProcessor.class)
    public CronCallbackPostProcessor cronCallbackPostProcessor(){
        return new DefaultCronCallbackPostProcessor();
    }

    @Bean
    @ConditionalOnMissingBean(CronCallback.class)
    public CronCallback cronCallback(){
        return new OkHttpCronCallback();
    }
}
